package com.fa4j.system.settings.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 系统字典批量保存请求参数
 */
@Data
public class SystemDictBatchSaveRequest {

    /**
     * 根节点字典编码
     */
    @NotEmpty
    private String rootCode;

    /**
     * 根节点名称
     */
    @NotEmpty
    private String rootName;

    @NotNull
    private String valueType;

    @NotNull
    private Integer maxLevel;

    private List<@Valid DictCustomField> customFields;

    /**
     * 操作人
     */
    @NotNull
    private Long operatorId;

    /**
     * 字典集合
     */
    @NotEmpty
    private List<@Valid Item> items;

    public record DictCustomField(
            @NotEmpty String name,
            @NotEmpty String title,
            @NotEmpty String type,
            @NotEmpty Boolean nullable) {
    }

    public record Item(
            @NotEmpty String dictName,
            @NotEmpty String dictCode,
            String dictValue,
            Integer priority,
            @NotEmpty String parentCode,
            Map<String, Object> customData
    ) {
    }
}
